package com.example.backend.controller;


import com.example.backend.pojo.Result;
import com.example.backend.pojo.User;
import com.example.backend.pojo.Usertype;
import com.example.backend.service.UsertypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/usertype")
public class UsertypeController {
    @Autowired
    private UsertypeService usertypeService;

    @GetMapping("getall")
    public Result<List<Usertype>> getall(){
        return Result.success(usertypeService.getall());
    }
    @PostMapping("/update")
    public Result update(@RequestBody  Usertype usertype)
    {
        usertypeService.update(usertype);
        System.out.println(usertype);
        return Result.success();
    }

    @PostMapping("/getuser")
    public Result<List<User>> getuser(String usertypeid)
    {
        return Result.success(usertypeService.getuser(usertypeid));
    }

}
